package knowse.app.daos;

import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class TestStatusDetailDAO {
	private final String TAG = "TestStatusDetailDAO";
	private final String ERRORMSG = "Insertion failed";
	protected static final String Table = "TestStatusDetail";
	protected static final String Location = "Location";
	protected static final String Class_ = "Class";
	protected static final String Method = "Method";
	protected static final String Message = "Message";
	protected static final String Type = "Type";
	protected static final String ID = "_ID";
	protected static final String Backtrace="Backtrace";
	//foreign key.
	protected static final String TestStatusTimeStamp = "TestStatusTimeStamp";
	
	public TestStatusDetailDAO(){
		
	}
	
	
	
	//insert methods to retrieve and update the database

	/*
	 * TODO
	 */
	public void store(TestStatusDetailDataObject tdo) throws Exception{
		ContentValues values= new ContentValues();
		values.put(Class_, tdo.getTestClass());
		values.put(Location, tdo.getLocation());
		values.put(Message, tdo.getMessage());
		values.put(Method, tdo.getMethod());
		values.put(Type, tdo.getType());
		values.put(Backtrace, tdo.getBacktrace());
		values.put(TestStatusTimeStamp, tdo.getTimeStamp().getTime());
//		values.putNull(ID);
		
		//TODO
		DBHelper dbHelper=new DBHelper();
		
		SQLiteDatabase db=dbHelper.getWritableDatabase();
		
		long insertResult = db.insert(Table, null, values);
		if(insertResult < 0){
			throw new Exception(TAG + " " + ERRORMSG);
		}
		db.close();
	}
	
}
